// pages/zlk/zlk.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    session_key: '',
    tabCur: 0, //题型题量复习指导
    tabs: [{
      name: '2023山东省考',
      id: 0
    }],
    list: 0,
    lists: [
      
      [{
          title: '跟随“习”语学古语',
          sid: 0
        },
        {
          title: '时代热词',
          sid: 1
        },
        {
          title: '走进党的二十大',
          sid: 2
        }]
    ],
    scrollLeft: 0
  },
  prevImg: function () {
    var _ = this;
    var scrollLeft = _.data.scrollLeft
    if (scrollLeft > 50) {
      scrollLeft = scrollLeft - 200
    }
    _.setData({
      scrollLeft
    })
  },
  nextImg: function () {
    var _ = this;
    var scrollLeft = _.data.scrollLeft
    if (scrollLeft < 1400) {
      scrollLeft = scrollLeft + 200
    }
    _.setData({
      scrollLeft
    })
  },
  topdf(e) {
    var that = this;
    var phone = wx.getStorageSync('52396phone')
    if (phone) {
      console.log(e.currentTarget.dataset.sid)
      var sid = e.currentTarget.dataset.sid;
      wx.navigateTo({
        url: '../pdf/pdf?sid=' + sid,
      })
    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 2000
      });
      wx.navigateTo({
        url: '../login/login',
      })
    }
  },



  //选择条目
  tabSelect(e) {
    console.log(e.currentTarget.dataset.id)
    this.setData({
      list: e.currentTarget.dataset.id,
      tabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id) * 200
    })
  },
  tohb() {
    wx.navigateTo({
      url: '../tuiwen/tuiwen',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log(options);
    that.setData({
      area: options.area,
      geneal: options.agent
    })
    if (options.page) {
      that.setData({
        page: options.page
      })
    }

    wx.login({
      success(res) {
        console.log(res)
        if (res.code) {
          wx.request({
            url: 'https://tgadmin.sdwx.zgkfpt.cn/api/v1/program/wx_login',
            method: 'POST',
            data: {
              code: res.code,
              id: that.data.activity_id
            },
            success: res => {
              console.log(res.data.session_key);
              that.setData({
                session_key: res.data.session_key
              })
            }
          })
        } else {
          console.log('登录失败！' + res.errMsg)
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})